<?php 
	session_start();
	include("ketnoi.php");
?>
<div class="timkitu">

	<h5>TIN TỨC & SỰ KIỆN<HR ></h5>
	<form method="post" name="f_timgia" > 
	<ul>
	<?php	
	$query = "SELECT * FROM `".$dulieu."`.`tintuc` WHERE  MaTT=(select max(MaTT) from tintuc)";	
	$kq = mysql_query($query);
	$row = mysql_fetch_array($kq);
	if($row["TieuDeTT"] !=''){
	?>
    <li style="border-bottom:1px #999999 dotted; margin-right:10px"><a href="c01<?php echo $row["MaTT"]?>.html" title="<?php echo $row['TieuDeTT']?>"><?php echo catchuoi($row["TieuDeTT"],0,50)?></a></li>
	<?php
	}
	$n=1;
	$tnm=$row['MaTT'];
    while($n<5){
	$sqlhkl = "SELECT * FROM `".$dulieu."`.`tintuc` order by MaTT desc ";
    $giatritravehkl = mysql_query($sqlhkl);
	    while($dongDLHKL = mysql_fetch_array($giatritravehkl)){	
			if($dongDLHKL['MaTT'] < $tnm){
					    $nm=$dongDLHKL['MaTT'];
						$tin=$dongDLHKL['TieuDeTT'];
	?>
            <li style="border-bottom:1px #999999 dotted; margin-right:10px"><a href="c01<?php echo $nm ?>.html" title="<?php echo $tin?>"><?php echo catchuoi($tin,0,50)?></a></li>	
	<?php
			}
		}
		$tnm=$nm;
		$n=$n+1;
	}
	?>
	</ul>
	</form>
</div>

<div class="timkitu">

	<h5>LỊCH HỌC<HR ></h5>
	<form method="post" name="f_timgia" > 
	<ul>
    <?php
				$query2 = "select * from  `".$dulieu."`.`coso` where TrangThai = 1 order by MaCS asc";
				$kq2 = mysql_query($query2);
				while($row2 = mysql_fetch_array($kq2))
				{?>
				<li style="border-bottom:1px #999999 dotted; margin-right:20px"><a href="cs_<?php echo $row2['MaCS'] ?>.html">Cơ Sở <?php echo $row2['TenCS'] ?></a></li>
				<?php
				}
				?>
	
	</ul>
	</form>
</div>

<div  style="margin-top:3px;">
<a href="dangky.html"><img src="images/tinh.gif" width="230" height="76" /></a>
</div>

<div class="timkitu">

<h5>HỎI ĐÁP<HR ></h5>
	<form method="post" name="f_timgia" > 
	<ul>
	<?php
	$query = "select max(MaCH) as MaCH  from `".$dulieu."`.`hoidap` where NoiDungTL != ''";	
	$kq = mysql_query($query);
	$row = mysql_fetch_array($kq);
	$query = "select *  from `".$dulieu."`.`hoidap` where MaCH= '".$row["MaCH"]."'";	
	$kq = mysql_query($query);
	$row = mysql_fetch_array($kq);
	if($row["TieuDe"] !=''){
	?>
    	<li style="border-bottom:1px #999999 dotted; margin-right:10px"><a href="hd01<?php echo $row["MaCH"] ?>.html" title="<?php echo $row['TieuDe']?>"><?php echo catchuoi($row["TieuDe"],0,30)?></a></li>
    <?php
	}
	$n=1;
	$tnmm=$row['MaCH'];
    while($n<5){
	$sqlhkl = "SELECT * FROM `".$dulieu."`.`hoidap` where NoiDungTL != '' order by MaCH desc ";
    $giatritravehkl = mysql_query($sqlhkl);
	    while($dongDLHKL = mysql_fetch_array($giatritravehkl)){	
			if($dongDLHKL['MaCH'] < $tnmm){
					    $nmm=$dongDLHKL['MaCH'];
						$tinm=$dongDLHKL['TieuDe'];
	?>
            <li style="border-bottom:1px #999999 dotted; margin-right:10px"><a href="hd01<?php echo $nmm ?>.html" title="<?php echo $tinm ?>"><?php echo catchuoi($tinm,0,30)?></a></li>	
	<?php
			}
		}
		$tnmm=$nmm;
		$n=$n+1;
	}
	?>
	</ul>
	</form>
</div>

<div class="timkitu">

	<h5>TƯ VẤN<HR ></h5>

	    <?php
				$query2 = "select * from  `".$dulieu."`.`coso` where TrangThai = 1 order by MaCS asc";
				$kq2 = mysql_query($query2);
				while($row2 = mysql_fetch_array($kq2))
				{
				if($row2['SDT']!=''){
				?>
<table width="100%" style="padding-left:10px">
  <tr>
    <td colspan="2"><span style="color: #00F; font-size:14px;">
                <?php echo $row2['TenCS']; ?> </span></td>
  </tr>
  <tr>
    <td width="3%"  style="padding-left:10px"><img src="images/dt.png" width=20 height=20/></td>
    <td width="97%"><span style="color:#F00; font-size:14px; font-weight:bold;">
                <?php echo $row2['SDT']; ?> </span></td>
  </tr>
</table>

				<?php
				}
				}
				?>
</div>

<div class="timkitu1">

	<h5>LƯỢT TRUY CẬP<HR ></h5>
<div align="LEFT" style="padding-left:10px;color:#000; font-size:14px; font-weight:bold;">
<?php	
      
	    $session=session_id();
		$time = time();
		$time_check = $time-300; 

		
		$sql1 = "SELECT count(*) as sl FROM `user_online` WHERE session='".$session."'";
		$kq = mysql_query($sql1);
		$count = mysql_fetch_array($kq);

		if($count['sl'] == 0){
			$sql_insert = "INSERT INTO `user_online`(session, time)VALUES('$session', '$time')";
			$insert = mysql_query($sql_insert);
			
		    $sql1 = "SELECT count FROM `user_view`";
		    $kq = mysql_query($sql1);
		    $count_user_view = mysql_fetch_array($kq);
		    $count_user_view = $count_user_view['count']+1;
			
			$sql_update = "UPDATE `user_view` SET count = '".$count_user_view."'";
			$update = mysql_query($sql_update);
		}
		else {
		
			$sql_update="UPDATE `user_online` SET time='$time' WHERE session = '$session'" ;
			$update = mysql_query($sql_update);
		}

		$sql1 = "SELECT count(*) as sl FROM `user_online`";
		$kq = mysql_query($sql1);
		$count_user_online = mysql_fetch_array($kq);
		
		$sql1 = "SELECT count FROM `user_view`";
		$kq = mysql_query($sql1);
		$count_user_view = mysql_fetch_array($kq);
		
		$sql1 = "DELETE FROM `user_online` WHERE time<$time_check";
		$kq = mysql_query($sql1);
        
		

?>
KHÁCH ONLINE: <?php echo $count_user_online['sl']; ?><BR />
LƯỢT TRUY CẬP: <?php echo  $count_user_view['count']; ?> 
</div>
</div>
			